fixed broken reverse priority calculate field statement

and added bunch of documentation