Bug fixes and final commit