Rollback before merge and some code clean up