Code cleanup/speedup