fixed ugly cast and obsolete library declaration