code formatting and cleanup