port from HTC Pico. needs editing