Reapplied lost fix and small improvements

This fixes #1 and #2