moved stuff around, added comments