Fix narrowing conversion errors for recent gcc versions. Closes issues 47 and 49.