fixed allocation conflicts as well as few minor bugs