Completed script

more bug fixes, ring declaration is complete.