Cleaned code, removed excess logging