Some bug fixes and code cleanup