Cleaned up template, removed repetion (DRY), etc.