bug fixes... still not perfect