First version of method.
Fix some bugs. Clean code.
Attach. Tests fixes. Two tests for attach.