Adopted changes from the touchscreen toolkit