Added documentations. fixed returns. Fixed code style.