added preliminary V4L support, cleaned up code