Cleanup

Here are several proposals: some are merely a matter of taste, some are real improvements (template), one is critical (Random). Feel free to cherry-pick, it's up to you.