Cleaned up code and fixed issues with calling cassandra when not needed.