fixed runtime errors & some error catching.

no further errors that i am aware of. check for more error handling