Added comments and doc generation (quite ugly for now)