Improved speed, consolidated to one file