Error handling

Added assertions in calculatePenalty to aid in debugging