Fix refactoring oversight
Clean up style logic a little and make template parsing more robust