Code Cleanup and escaping foreign encoding support

This should fix #4. Could you take a look at it @elbuo8?