Can't stands no more. Fixed some JS bugs and added null checking in query #1.