Fixes and error checking