- fix few bogosities here and there; - move some common routines into the library. MFC after: 2 weeks