Temporarily comitted KHobbit's code

Updated to KHobbit's code.
Note: Not tested - will do when out of school. Also will need formatting.