Move some code + more documentation