Refactored and added some coord utilities based on ideas from @AtomicBlom