better error reporting + some small fixes