Remaining changes and bug fixes