Fixed bugs, including the json_encoding bug