clean up code format, remove old segments