Now passing tests.

There were some errors with not declaring a nanscope. Also not returning
on errors.
fixed indentation for my changes (hopefully)