Cleanup, documentation, compression (DRY)

don't create functions where none is needed.