Changed from ints to doubles for more precision.
Pretty much done now.