Solved encoding problem and minor fixes