Code cleanup, high-level patterns