Major refactor 2