Added save and load functions, trimmed some fat