added helper functions, fixed bias unit and no-hidden-layer bugs