Refactored code + fixed bug in resizing method + updated tests, docs