Added formencode dependency
Tweaked various queries for better performance