typos fix'd and restore some code that shouldnt have been deleted