Minor bug fixes and removing dead code