general Overhaul and bug fixes