Cleaned up old code though new code not yet fully working