Added logging support and fixed issuese