- updated with bug fixes in various places