Improved code. Added todos.