fixed some minor bugs regarding encoding