Fixed silly mistakes in code. Still plenty to add.