Removed the public fields and did some refactorings