code merge and bug fixes