Cleaned code and improved automation