Some cleanups to improve speed