Changes for clarity, SP13
part2&3
bug fixes
added rag's code
merged with prev