Added saving and loading, fixed some bugs