Fixed several bugs and applied newly changed queries.