(Unstable) About to refactor to simplify input and value preprocessing