Fixes #23, handle errors, few bugfixes and optimization