code cleanup, added comments, reworked client.js, removed locations count and template logic