cleanup of the code and performance optimizations with less methods called per request