some changes to make things pickle compatible...