Fixed position handling

Copied position function from gradient-everything