Added calculator for basic measures and DB writing - needs testing