Internal changes, better datatypes

Some code tidying and more importantly, use better data types (decimal and datetime rather than float and int).