restructure and clean a bit