added writeShort
improved logging