Minor bug fixes after input from tony