clean the code a bit. added support for load/save