Bug Fixes and Optimizations For Les_Engine

most queries updated to be stored procedures.