merge changes and fix bugs