Merge spacecheck function into main script, implemented beginnings of error handling.