cleanup and re-structure