Cleaned up some code repetition in embind