clean up, modify contact listener, move some functions