Major changes to structure and code