Various bug fixes. Ported text rendering code.