fixed lots of bugs in data initialization