Bugfix and little improvements pullrequest