more error handling
bugfixings