better error checking for failed setup steps, code cleanup