saving + loading + restructuring for nicer library usage