some error checking, cleanup

Signed-off-by: Joel Anna <annajoel@pdx.edu>