Cleaned apsw code