handle sub-types better and improve errors to include line/byte numbers