fix compilation and run time issues