Error detection implemented and clean-ups

Implemented the error handling and removed more unneeded files. Getting
pretty clean now.