Major refactor done