fixed merge issues and re-integrated changes from merge that were discarded