Major refactoring + loading from file