functionally complete and bug fixes