Some refactoring & code commenting