Polished code and script fixes