Code cleanup/performance improvement