massive fixes to neural netowrk script