Finished major refactor