Remove console.logs and some refactoring