Major rewrite of the codebase to follow actual standards