Codecleanup and small improvements