Finalize rendering hat + cleanup of code