Separated some methods to more specific functions. Removed unused variables.