Code cleaned up gets slightly better performance now.