Fixed some bugs in tablet support