Fixed and reused lib code for alpino client