added configurable numbers of hidden layers, fixed some minor bugs