Fully implemented MLP layer as native extension (needs tidying)