Small bug fixes and annoying compiler warnings on os x.