removed unused stuff and refactored a bit