Refactored and fixed reset stuff