added loading/saving, some minor bugifixng