Major changes and bug fixes