Added support for iPad and fixed a few bugs