Big clean up and bug fixes for updated code  has been updated