Remove unused variables
Split up code into multiple methods.