Moved some annotation logic from the template to the main js file, solving #40