Added necessary methods.
And also cleaned up a lot.