Syntax: safer use of unsafePerformIO

prevent sharing of labels
Use a single input for mempty
minor speedups and cleanup