Cleaned up

Fixed unused values, moved things around, and printed out the error if keys not present.