some refactoring + global const EPS, TICK