added lots of new things and refactored some others