safely write scene file
made protected to private, fixed code of compiler warnings