Implement precedence in a less hacky and more documented way.