More cleanups to simplify the code