Added better handling of user input.

moved ifndef's to top of file.