fixed some errors, improved definitions