Get log counts per application working

Need to do some serious refactoring. Mapping code is horrible and there
has to be a better way to do the queries.