Fix for "class not serializable" exception