Huge bug fixes