Refactor initialization, add documentation