added lots of functionality to allow various neat features and stuff