More cleanup & optimization