made some small bug fixes and code cleanings