Cleanup, use g.resource and g.createLink instead of manually constructing URLs, and add javadoc