Almost all functions implemented, just need a test and to fix the line writing.