code cleanup, uses javascript promises better, removes crazy callbacks, etc.