bug fixes and merge half-implemented