Added prefferences

Added preferences and tidied up a bit