Seemingly fixed the problem with adding/overwriting. Also, started fixing codestyle.