Implementation of some calculation routines