Add support for percent calculations based on holgersindbaek's code