Minor bug fixes and improvementsY