fixed numerous small bugs