Improved queries, cleaned code.