Added settings page and lots of bug fixes