Refactored common euler code to be cleaner.