Major bug fixes all-around