Added tick unwrapping step, pulled out variables