tuned sparse matrix operations; encapsulated layer classes better