Bug fixes and stuff