improved modularization and fixed some pickling bugs