basedir set as global variable fix functions

Also removed keyboard patch as currently not working anyways.  Other
small fixes to script.