Added fixes mentioned by @dereuromark