Added Error Handling, lazy querying (tm) for just about everyting
Merged Paul's changes. New funtions untested though