Code cleanup, optimization, fun stuff