re-orginization and bug fixes