Error handling, bugfixes

Resolved #6, #7 , bugfixes, error handling