Updates at various places

o improves and introduces new functionality on high level
o adds better error handling
o introduces unit tests
o updates documentation in various places