Fully implemented totals on result,
added more type checks and conversions